package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entity.Book;
import service.ProductService;

/**
 * Servlet implementation class FindProtuctByManyConditionServlet
 */
public class FindProductByManyConditionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 获取查询条件
		String id=request.getParameter("id");
		String name=request.getParameter("name");
		String category=request.getParameter("category");
		String minprice=request.getParameter("minprice");
		String maxprice=request.getParameter("maxprice");
		//创建service对象
		ProductService service =new ProductService();
		List<Book> ps=service.findProductByManyCondition(id,name,category,minprice,maxprice);
		//把商品信息保存
		request.setAttribute("ps", ps);
		//转发道list.jsp回显信息
		request.getRequestDispatcher("/admin/products/list.jsp").forward(request, response);
		
		
		
	}

}
